<?php
/*
 * @Author: 李志刚
 * @CopyRight: 2022-2099 李志刚（854378082@qq.com）
 * @Date: 2021-03-16 10:11:52
 * @Description: 友情链接分类
 * @LastEditors: 李志刚
 * @LastEditTime: 2022-04-20 21:09:15
 * @FilePath: /CoinCMF/app/Models/Content/LinkType.php
 */

namespace App\Models\Content;

use DateTimeInterface;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Factories\HasFactory;

class LinkType extends Model
{
    use HasFactory;
    /**
     * The table associated with the model.
     *
     * @var string
     */
    protected $table = 'cms_link_type';
    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $guarded = [];
    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $hidden = [];

    /**
     * 表明模型是否应该被打上时间戳
     *
     * @var bool
     */
    public $timestamps = true;
    // 自动生成的时间要加时区约束
    public function serializeDate(DateTimeInterface $date): string
    {
        return $date->format('Y-m-d H:i:s');
    }

    protected $casts = [
        'id' => 'integer'
    ];
    // 关联
    public function links()
    {
        return $this->hasMany('\App\Models\Content\Link', 'linktype_id', 'id');
    }
}
